package filter.request;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;

public class RequestServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //后台接收中文乱码问题
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        //获取前端内容
        String uname = req.getParameter("uname");
        String upwd = req.getParameter("upwd");

        String[] hobbies = req.getParameterValues("hobby");
        System.out.println("=============================");
        //后台接收中文乱码问题
        System.out.println(uname);
        System.out.println(upwd);
        System.out.println(Arrays.toString(hobbies));
        System.out.println("=============================");

        resp.sendRedirect("/4_Request_war/success.jsp");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
